Skip to content

Add window::open_dialog for windows parented to another process - #4

Open
kevinard wants to merge 1 commit into
canopa/basefrom
canopa/open-dialog
Open

kevinard wants to merge 1 commit into
canopa/basefrom
canopa/open-dialog

Conversation

@kevinard

Copy link
Copy Markdown
Owner

Canopa fork tracking PR. Its diff against canopa/base (595af03, the tip of upstream's 0.14 branch when iced_widget 0.14.2 was released. iced_winit and iced_runtime there are identical to the 0.14.0 release, 3997291) is exactly the change Canopa carries in iced_winit/iced_runtime. It is merged into canopa/main, which Canopa builds. This PR stays open until the change is upstreamed or dropped.

What

  • iced_runtime: window::open_dialog(handle, modal, settings), window::open_dialog_with_activation(handle, modal, token, settings) and Action::OpenDialog. The handle is an xdg-foreign handle without the wayland: prefix.
  • iced_winit: Control::CreateWindow carries the handle, modal hint and optional activation token, and transient::dialog_attributes applies them with winit's Wayland with_foreign_parent and with_activation_token before the first commit. The task yields Some(id) once open.
  • The open channel becomes OpenResponse (Normal / Transient). This branch is independent of canopa/open-transient, which adds the same enum, so each PR pins exactly one winit topic. canopa/main contains the combined version.

winit pin: the root Cargo.toml adds [patch.crates-io] winit = { git = "https://github.com/kevinard/winit", rev = "021f33898bc9…" }, pointing at kevinard/winit canopa/wayland-foreign-parent (import a foreign parent and dialog hint before the initial configure). Cargo.lock is updated to match. canopa/main pins winit's canopa/main instead.

Why

Canopa's FileChooser and AppChooser portal backends run Iced dialogs on behalf of other applications. Those dialogs must be parented, and optionally modal, to the caller's exported toplevel, and must use the incoming activation token. See Canopa ADR 0026 and 0028.

Verification

  • cargo check --locked --all-targets -p iced_winit -p iced_runtime -p iced_test (default features) and cargo check --locked -p iced --no-default-features --features advanced,wgpu,crisp,web-colors,thread-pool,wayland,image (Canopa's selection) pass at this branch. The only warning is the pre-existing f32::INFINITY deprecation in iced_widget.
  • cargo test --locked -p iced_winit -p iced_runtime --lib passes.
  • In Canopa: both portal backends open their dialogs through this action.

Upstream

Upstream it, together with xdg-foreign support in winit (none upstream). Known gap to fix first: on non-Wayland backends OpenDialog opens an unparented window instead of returning None as documented. The [patch.crates-io] pin is fork-only and goes away once winit provides the API.

🤖 Generated with Claude Code

A window shown on behalf of another application (a desktop portal file
or application chooser, for example) must be parented to that
application's toplevel, which only exists as an exported xdg-foreign
handle, and may carry a startup activation token.

Add `window::open_dialog(handle, modal, settings)`,
`window::open_dialog_with_activation(handle, modal, token, settings)`
and `Action::OpenDialog`. The `winit` shell passes the handle, modal
hint and token through `Control::CreateWindow` and applies them with
winit's Wayland `with_foreign_parent` and `with_activation_token`
attributes before the first commit. The task resolves to `Some(id)`
once the window is open. The open channel becomes an `OpenResponse`
carrying either kind of sender.

Known gap: on non-Wayland backends the dialog currently opens as an
unparented window rather than resolving to `None`.

Requires winit's `WindowAttributesExtWayland::with_foreign_parent`;
`Cargo.toml` patches winit to the fork commit that provides it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant